﻿// <copyright file="SkeletonDataExtensions.cs" company="Ucaya">
// </copyright>
// <author>Ucaya</author>

namespace KinectExtensions.Extensions
{
    #region

    using System.Collections.Generic;

    using KinectExtensions.Services;

    using Microsoft.Research.Kinect.Nui;

    #endregion

    /// <summary>
    ///   TODO: Update summary.
    /// </summary>
    public static class SkeletonDataExtensions
    {
        #region Constants and Fields

        private static readonly Dictionary<string, JointGestureService> GestureServiceCache = new Dictionary<string, JointGestureService>();

        #endregion

        #region Public Methods

        public static JointGestureService GetJointGestureService(this SkeletonData skeleton, JointID jointId)
        {
            string id = skeleton.TrackingID + "_" + jointId;
            JointGestureService svc;
            if (!GestureServiceCache.TryGetValue(id, out svc))
            {
                svc = new JointGestureService(jointId);
                GestureServiceCache[id] = svc;
            }

            return svc;
        }

        #endregion
    }
}